﻿<html>

<head>

<!--COMMON :include style and javascript code-->
${inc:/action/pub/common}

<title>量房录入信息</title>

</head>

<body onmouseup="hidInputValidatorTip(3);">
<!--a name="A0" id="A0"></a-->

<!--COMMON HEADER-->
${inc:/action/pub/header}

<center>

<!--filter form-->
<div id="divFilter" style="display:none;width:100%">
</div>

<!--addnew/edit form-->
<div id="divEditor" style="display:none;width:100%">
</div>

<!--insert/update response-->
<div id="divEditorResponse" style="display:none;width:100%">
</div>

<!--grid view response-->
<div id="response" style="display:none;width:100%">
</div>

<!--progress indicator-->
<div id="divStatus" class="alert" style="text-align:left; display:none;color:gray;width:150px;font-weight:bold;font-family:Arial">
    <img src="${def:context}/images/progress.gif"> 请稍候...
</div>

<!--show linked grid-->
<iframe id="detail" name="detail" marginwidth="0" scrolling="no" frameborder="0" style="height:0%;width:100%;visibility:hidden">
</iframe>

<!--用于传递当前目录到header模版中-->
<input type="hidden" name="actionroot" id="actionroot" value="${def:actionroot}">

</center>

</body>

</html>

<SCRIPT LANGUAGE="JavaScript">

//计算院内设施总额
function countYuanneiFee(){
	var array = new Array("dijiao2","shu2","guoshu2","shuijin_shouya2","chuqinshepeng2","shuijin_qita2",
						"zhaoqichi2","yuanqiang2","teshuguoshu_l12","teshuguoshu_l22",
						"teshuguoshu_l32","teshuguoshu_l42","teshuguoshu_l52","zhujuan2",
						"zilaishui2","cesuo2","shuinishe2","dianhua2","youxiandianshi2",
						"menlou_yi2","menlou_er2","fengbiyuanqiangmen2","banfengbiyuanqiangmen2");
	var totalFee = 0;
	for(var i=0;i<array.length;i++){
		var obj = document.forms["formEditor"].elements[array[i]];
		if(Trim(obj.value)==""){
			continue;
		}
		totalFee += parseFloat(Trim(obj.value));
	}
    //anthony 2010-5-12 小房除一等之外的所有费用合计 begin
    //alert("totalFee1:"+totalFee);
    var xiaofang_noyideng = getXiaofangFee();
    totalFee = totalFee +xiaofang_noyideng;
    //alert("totalFee2:"+totalFee);
    //anthony 2010-5-12 小房除一等之外的所有费用合计 end
	document.forms["formEditor"].elements["total_fee"].value = eval((Math.round(totalFee*100))/100);
}
//anthony 2010-5-12 小房除一等之外的所有费用合计 begin
function getXiaofangFee(){
    var totalFee = 0;
    //小房等级字段名前缀
    var xf_level = "xf_level";
    //小房价格字段前缀
    var xf_total = "xf_total";
    for(var i=1;i<=6;i++){
        //等级对象
        var levelObj = document.forms["formEditor"].elements[xf_level+i];
        //金额对象
        var totalObj = document.forms["formEditor"].elements[xf_total+i];
        if(Trim(levelObj.value)!= "一等"){
            if (parseFloat(Trim(totalObj.value)) >0)
            {
                totalFee += parseFloat(Trim(totalObj.value));
            }
        }
    }
    if (IsNumeric(totalFee))
    {
        return totalFee;
    }
    return 0;
}
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
};
//anthony 2010-5-12 小房除一等之外的所有费用合计 end
function onBlurHandler(price,ge,show){
	var p = document.forms["formEditor"].elements[price];
	var g = document.forms["formEditor"].elements[ge];
	var s = document.forms["formEditor"].elements[show];
	if(Trim(p.value)=="" || Trim(g.value)==""){
		return false;
	}
	var pVal = parseFloat(p.value);
	var gVal = parseFloat(g.value);
	if(gVal >= 0){
		var output = eval((Math.round(pVal*gVal*100))/100);
		s.value = output;
	}else{
		alert("请输入正确格式");
		g.focus();
		g.select();
		return false;
	}
	countYuanneiFee();
}

function MyCheckDouble(val)
{
	var obj = document.forms["formEditor"].elements[val];
    var input = obj.value;
	if(input == "") return true;
    var pos1 = input.indexOf(".");
    var pos2 = input.lastIndexOf(".");
    var charset = "1234567890.";
    if ((pos1 != pos2)||(!CheckChar(charset, input, true))) {
        alert ("请输入正确格式，只可包含数字和一个“.”！");
        obj.focus();
        obj.select();
        return false;
    }
	var output = eval((Math.round(input*100))/100);
	obj.value=output;
    
    return true;
}

//字段校验
function checkFields(){
	if(CheckNull("master_name","formEditor","请输入户主姓名！")) return false;
	//if(CheckNull("project_name","formEditor","请选择项目名称！")) return false;
	if(CheckNull("cun_name","formEditor","请选择所在街道和村屯！")) return false;

	if(!CheckRadio("is_touqin","请选择是否投亲","","formEditor")) return false;

    if(!MyCheckDouble("zf_number1"))return false;
	if(!MyCheckDouble("zf_area1"))return false;
	if(!MyCheckDouble("zf_price1"))return false;
	if(!MyCheckDouble("zf_number2"))return false;
	if(!MyCheckDouble("zf_area2"))return false;
	if(!MyCheckDouble("zf_price2"))return false;

	if(!MyCheckDouble("xf_area1"))return false;
	if(!MyCheckDouble("xf_price1"))return false;
	if(!MyCheckDouble("xf_total1"))return false;
	if(!MyCheckDouble("xf_area2"))return false;
	if(!MyCheckDouble("xf_price2"))return false;
	if(!MyCheckDouble("xf_total2"))return false;
	if(!MyCheckDouble("xf_area3"))return false;
	if(!MyCheckDouble("xf_price3"))return false;
	if(!MyCheckDouble("xf_total3"))return false;
	if(!MyCheckDouble("xf_area4"))return false;
	if(!MyCheckDouble("xf_price4"))return false;
	if(!MyCheckDouble("xf_total4"))return false;
	if(!MyCheckDouble("xf_area5"))return false;
	if(!MyCheckDouble("xf_price5"))return false;
	if(!MyCheckDouble("xf_total5"))return false;
	if(!MyCheckDouble("xf_area6"))return false;
	if(!MyCheckDouble("xf_price6"))return false;
	if(!MyCheckDouble("xf_total6"))return false;

	if(!MyCheckDouble("dijiao"))return false;
	if(!MyCheckDouble("dijiao2"))return false;
	if(!CheckNullNum("shu"))return false;
	if(!MyCheckDouble("shu2"))return false;
	if(!CheckNullNum("shuijin_shouya"))return false;
	if(!MyCheckDouble("shuijin_shouya2"))return false;
	if(!CheckNullNum("shuijin_qita"))return false;
	if(!MyCheckDouble("shuijin_qita2"))return false;
	if(!MyCheckDouble("chuqinshepeng"))return false;
	if(!MyCheckDouble("chuqinshepeng2"))return false;
	if(!MyCheckDouble("guoshu"))return false;
	if(!MyCheckDouble("guoshu2"))return false;

	if(!CheckNullNum("zhaoqichi"))return false;
	if(!MyCheckDouble("zhaoqichi2"))return false;
	if(!MyCheckDouble("yuanqiang"))return false;
	if(!MyCheckDouble("yuanqiang2"))return false;
	if(!CheckNullNum("teshuguoshu_l1"))return false;
	if(!MyCheckDouble("teshuguoshu_l12"))return false;
	if(!CheckNullNum("zhujuan"))return false;
	if(!MyCheckDouble("zhujuan2"))return false;
	if(!CheckNullNum("zilaishui"))return false;
	if(!MyCheckDouble("zilaishui2"))return false;
	if(!CheckNullNum("teshuguoshu_l2"))return false;
	if(!MyCheckDouble("teshuguoshu_l22"))return false;
	if(!CheckNullNum("teshuguoshu_l3"))return false;
	if(!MyCheckDouble("teshuguoshu_l32"))return false;
	if(!CheckNullNum("cesuo"))return false;
	if(!MyCheckDouble("cesuo2"))return false;
	if(!MyCheckDouble("shuinishe"))return false;
	if(!MyCheckDouble("shuinishe2"))return false;
	if(!CheckNullNum("teshuguoshu_l4"))return false;
	if(!MyCheckDouble("teshuguoshu_l42"))return false;
	if(!CheckNullNum("teshuguoshu_l5"))return false;
	if(!MyCheckDouble("teshuguoshu_l52"))return false;

	if(!CheckNullNum("dianhua"))return false;
	if(!MyCheckDouble("dianhua2"))return false;
	if(!CheckNullNum("youxiandianshi"))return false;
	if(!MyCheckDouble("youxiandianshi2"))return false;
	if(!CheckNullNum("menlou_yi"))return false;
	if(!MyCheckDouble("menlou_yi2"))return false;
	if(!CheckNullNum("menlou_er"))return false;
	if(!MyCheckDouble("menlou_er2"))return false;
	if(!CheckNullNum("fengbiyuanqiangmen"))return false;
	if(!MyCheckDouble("fengbiyuanqiangmen2"))return false;
	if(!CheckNullNum("banfengbiyuanqiangmen"))return false;
	if(!MyCheckDouble("banfengbiyuanqiangmen2"))return false;

	if(document.formEditor.liangfang_remak.value.length > 250){
		alert("备注信息长度不能超过250，请检查！");
		document.formEditor.liangfang_remak.focus();
		document.formEditor.liangfang_remak.select();
		return false;
	}

    return true;
}

function pickLevels(id,desc,flag){
	var url = "${def:context}/action/dq/pick/house-level/form";
	pickOpen (desc,id,url,'400','230',null,flag);
}

function searchBack(){
    document.getElementById("divFilter").style.display = "";
}

function loadFormBackSetting(){
	edit("${fld:id}");
}


function validateMasterName(val){
	if(val == "")return false;
	var tuid = document.forms["formEditor"].elements["tuid"].value;
    var newFlag = (tuid==""?true:(tuid=="0"?true:false));
	if(newFlag == false)return false;
	return ajaxCall(httpMethod="GET", 
                        uri="/action/dq/yewu/liangfang/findMaster" + "?master_name=" + encodeURIComponent(val), 
                        divResponse="divEditorResponse",
                        divProgress="divStatus", 
                        formName=null, 
                        afterResponseFn=null, 
                        onErrorFn=null);	
}

loadEditor(loadFormBackSetting);

</script>
    